import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import '../../../../../../lib_baseview/theme/jr.dart';
import '../../../../../../lib_baseview/utils/constant/text_styles.dart';
import '../../../tools/room_personal_data_page.dart';

class RoomRankItemWidget extends StatelessWidget {
  final int index;
  // final SimpleChannelUser item;
  // final SimpleChannelUser? nearbyUser;
  final bool showRankIcon;
  final bool showValue;
  final bool inRoom;

  const RoomRankItemWidget(
      {super.key,
      required this.index,
      // required this.item,
      // this.nearbyUser,
      this.showRankIcon = true,
      this.showValue = true,
      this.inRoom = false});
  // bool get rankHidden =>
  //     (GlobalConfig.settingsResp?.isInvisibleRank ?? false) && !inRoom;

  bool get rankHidden => false;
  @override
  Widget build(BuildContext context) {
    return Material(
      type: MaterialType.transparency,
      child: Ink(
        height: 80.h,
        child: InkWell(
          onTap: () {
            // if (inRoom) {
            //   RoomPersonalDataWidget.show(
            //       Get.context!, RootProxyModel.instance?.channel, item);
            // } else {
            //   PersonalHomePage.show(Get.context!, item.id.toInt());
            // }
          },
          child: Row(
            mainAxisSize: MainAxisSize.max,
            children: [
              Container(
                width: 47.w,
                alignment: Alignment.center,
                child: _rankIndex,
              ),
              // AvatarImage(
              //     url: StringUtil.formatImgUrl(item.avatar, size: 150),
              //     width: 42.w,
              //     height: 42.w,
              //     shape: BoxShape.circle),
              SizedBox(
                width: 12.w,
              ),
              Expanded(
                child: Column(
                  mainAxisSize: MainAxisSize.min,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text('nickname',
                        maxLines: 1,
                        overflow: TextOverflow.ellipsis,
                        style: JRTextStyles.styleFont14W600
                            .copyWith(color: JR.color.mainText)),
                    SizedBox(height: 4.h),
                    // Row(
                    //   mainAxisSize: MainAxisSize.min,
                    //   children: [
                    //     UserLevWidget(
                    //       vipImgStr: item.vipIcons.middleIcon,
                    //       itemH: 18.h,
                    //     ),
                    //     UserCarLevelWidget(
                    //       carLevel: item.car.carMetaInfo.level,
                    //       itemH: 18.h,
                    //       // job: item.job,
                    //     ),
                    //     UserKnightWidget(
                    //       itemH: 18.h,
                    //       imgStr: item.knightIcon,
                    //     )
                    //   ],
                    // ),
                  ],
                ),
              ),
              if (showValue) SizedBox(width: 10.w),
              if (showValue && !rankHidden)
                const Column(
                  crossAxisAlignment: CrossAxisAlignment.end,
                  mainAxisSize: MainAxisSize.min,
                  children: [
                    // Text(
                    //     StringUtil.getContributionStr(
                    //         item.contributionValue.toInt()),
                    //     style: JRTextStyles.styleFont14W600
                    //         .copyWith(color: JR.color.mainText)),

                    Text('contributionValue'),
                    // if (nearbyUser != null)
                    //   Text(nearbyDesc,
                    //       style: JRTextStyles.styleFont12W400
                    //           .copyWith(color: JR.color.secondaryText)),
                  ],
                ),
              if (rankHidden)
                Text('invisibiliting',
                    style: JRTextStyles.styleFont12W400
                        .copyWith(color: JR.color.secondaryText)),
              SizedBox(width: 20.w),
            ],
          ),
        ),
      ),
    );
  }

  Widget get _rankIndex {
    // if (item.rank < 0 || rankHidden) {
    //   return Text('-',
    //       style: JRTextStyles.styleFont14W600.copyWith(
    //           color: JR.color.secondaryText, fontFamily: 'DINAlternate-bold'));
    // }
    // if (index < 3 && showRankIcon) {
    //   return image('ic_rank_${index + 1}.png', width: 20, fit: BoxFit.fitWidth);
    // }
    return Text('${index + 1}',
        style: JRTextStyles.styleFont14W600.copyWith(
            color: JR.color.secondaryText, fontFamily: 'DINAlternate-bold'));
  }

  String get nearbyDesc {
    // int diff = (item.contributionValue - nearbyUser!.contributionValue).abs();
    // if (item.rank >= 0) {
    //   return T.current!.distance_previous_few_value(diff);
    // } else {
    // return T.current!.distance_rank_few_value(diff);
    return 'distance_rank_few_value';
    // }
  }
}
